<?PHP global $OnePress; global $current_user; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<?PHP wp_head() ?>
</head>
<body class="<?PHP echo $OnePress->layout->classname; ?>">
<div id="page">
	<?PHP do_action('op_header'); ?>
	<?PHP do_action('op_welcome'); ?>
	<?PHP do_action('op_navigation'); ?>
<?PHP

function op_favicon()
{
	echo '<link rel="icon" type="image/x-icon" href="/favicon.ico" />';
}

function op_feeds(){
	echo "\n".'<link rel="alternate" type="application/rss+xml" title="'; bloginfo('name'); echo' RSS Feed" href="'; echo bloginfo('rss2_url'); echo '" />';
	echo "\n".'<link rel="alternate" type="application/atom+xml" title="'; bloginfo('name'); echo' Comments RSS Feed" href="'; echo bloginfo('comments_rss2_url'); echo '" />';
	echo "\n".'<link rel="pingback" href="'; bloginfo('pingback_url'); echo '" />';	
}

function op_meta_title()
{
    echo '<title>'; 
	bloginfo('name');
	wp_title(' &raquo; ', true, 'left');
	echo '</title>';
}

function op_meta_description()
{
	echo '<meta name="description" content="';
	if ( is_single() ) { 
		wp_title(''); 
		echo ' - '; } 
	elseif ( is_page() ) { 
		wp_title(''); 
		echo ' - '; } 
	bloginfo('description');
	echo '" />';	
}

function fix_ie()
{
	echo <<<EOS
<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
<![endif]-->
EOS;
}

function op_header()
{
	?>
	<div id="header">
		<div class="hd"><div class="c"></div></div>
	  	
		<?PHP
		
			// Get user defined image
			if (($current_img = get_option('op_theme_header_img')) && $current_img != 0){
				if($files = wp_get_attachment_image_src($current_img, 'full')){
					$header_img = $files[0];
					$style = ' style="background: url(\''.$header_img.'\');"';
				}
			}
			else $style = '';
			
			echo '<div class="bd"><div class="c"'.$style.'>';
		?>
		<div id="headerimg" class="s">
		<?PHP do_action('op_header_content'); ?>
		</div>
		</div></div>
		<div class="ft"><div class="c"></div></div>
	</div>
	<?PHP
}

function op_header_content()
{
	?>
	<h1><a href="<?php echo get_option('home'); ?>/"><span><?php bloginfo('name'); ?></span></a></h1>
	<div class="description"><span><?php bloginfo('description'); ?></span></div>
	<div id="headerlink"><a href="<?php echo get_option('home'); ?>/"><span></span></a></div>
	<?PHP
}

function op_welcome()
{
	global $current_user; 	
	echo '<div id="welcome">';
	if(get_option('users_can_register') == 1){
		if($current_user->display_name == NULL){
			echo '<p><span>Welcome, please <a href="/wp-admin/">login</a> or <a href="/wp-login.php?action=register">register</a></span></p>';
		} 
		else{ 
			echo '<p>';
			
			// 2.7 introduced wp_logout_url() helper
			global $wp_version;
			preg_match('/([0-9\.]+)/',$wp_version,$version);
			if($version[0] >= 2.7)
				$logout_url = wp_logout_url();
			else
				$logout_url = '/wp-login.php?action=logout';
			
			printf(__('Welcome back, <a href="%1$s">%2$s</a>!  <a href="%3$s">Logout</a>'), '/wp-admin/profile.php', $current_user->display_name,$logout_url);
			echo '</p>';
		}
 	}
	echo '</div>';
}

function op_navigation()
{
	OP::default_nav();
}



?>